<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Admin;
use app\common\model\Banner;
use app\common\model\Grouping;
use app\common\model\Menu;
use app\api\library\WechatPay;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = '*';
    public function index()
    {
        $admin_id = $this->request->param('admin_id');
        $admin = Admin::where('id',$admin_id)->find();
        $banner = Banner::where(['admin_id'=>$admin_id,'status' => 1])->select();
        $menu = Menu::where(['admin_id'=>$admin_id,'status' => 1])->order('weigh asc')->select();
        $grouping = Grouping::where(['admin_id'=>$admin_id,'status' => 1])->order('weigh asc')->select();

        $data = [
            'banner' => $banner,
            'menu' => $menu,
            'grouping' => $grouping,
            'share' => [
                'title' => $admin['share_title'],
                'image' => $admin['share_image'],
            ]
        ];
        $this->success('获取成功',$data);
    }

    public function setNotify(){
        // $url = $this->request->param('url');
        $url = 'https://activity.xinyaoan.com/api/notify/coupon';
        $wechatPay = new WechatPay();
        $res = $wechatPay->setCallback($url);
        halt($res);
        $this->success('设置成功');
    }
}

